// list
import React, { Component } from "react";
import PropTypes from 'prop-types'
import "./index.css";
import Item from "../Item";
export default class List extends Component {
  static propTypes={
    update_todos:PropTypes.func.isRequired,
    todos:PropTypes.array.isRequired,
    handle_delete:PropTypes.func.isRequired

  }
  render() {
    // 对象数组
    let { todos } = this.props;
    return (
      <div>
        list
        {/* <Item /> */}
        {/* 这种return一定要记得包裹{} */}
        {todos.map((item) => {
          // return <Item key={item.id} name={item.name} done={item.done}/>;
          // 这种写法更好，item是一个对象。我们可以展开对象的方式当成属性传过去
          return (
            <Item
              key={item.id}
              {...item}
              update_todos={this.props.update_todos}
              handle_delete={this.props.handle_delete}
            />
          );
        })}
      </div>
    );
  }
}
